package cn.dz.heima04;

/**
 * @ClassName Student
 * @package: cn.dz.heima04
 * @Description 学生类
 * @Author dz
 * @Date 2025/2/5 16:33
 * @Version 1.0
 **/
public class Student {
    //成员变量
    String name;
    private int age;

    //提供get/set方法
    public void setAge(int a) {
//        age = a;

        if(a<0 || a>120) {
            System.out.println("你给的年龄有误");
        } else {
            age = a;
        }
    }

    public int getAge() {
        return age;
    }

    //成员方法
    public void show() {
        System.out.println(name + "," + age);
    }
}
